package com.surfilter.mq.validate.oprat;

import com.surfilter.mq.entity.WebsiteInfo;
import com.surfilter.mq.rocketmq.RocketMqMessageStandardOprate;
import com.surfilter.mq.rocketmq.cache.RockMqMesgManage;
import com.surfilter.mq.rocketmq.cache.RocketMqMessageStandard;
import com.surfilter.mq.rocketmq.exception.OprateException;
import com.surfilter.mq.validate.outernet.OuterNetValidate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

//import com.surfilter.mq.validate.website.WebSiteStatusService;

public class WebSiteStatusOperate extends RocketMqMessageStandardOprate {
	private static final Logger logger = LoggerFactory.getLogger(WebSiteStatusOperate.class);
	
//	private WebSiteStatusService webSiteStatusService;
	
	public WebSiteStatusOperate(RocketMqMessageStandard mesg,
			RockMqMesgManage manage) {
		super(mesg, manage);
		// TODO Auto-generated constructor stub
	}

	
	@Override
	public void opreateRocketMqMessageStandard(RocketMqMessageStandard mesg)
			throws OprateException {
		if(!validateOuternet()){
			logger.info("测试------外网网络无法访问.......................");
			return;
		}
		if(mesg instanceof WebsiteInfo){
			WebsiteInfo info = (WebsiteInfo)mesg;
			try {
				test();
//				WebSiteStatus webSiteStatus = webSiteStatusService.getWebSiteStatus(info);
//				webSiteStatusService.judgeYSFJR(webSiteStatus, info);
//				webSiteStatusService.JudgeDataOutsideOrNot(webSiteStatus, info);
//				webSiteStatusService.judgeYXZT(webSiteStatus,info);
//				webSiteStatusService.judgeYTSFBG(webSiteStatus, info);
//				webSiteStatusService.judgeSFTZ(webSiteStatus, info);
//				webSiteStatusService.judgeSJWH(webSiteStatus, info);
//				webSiteStatusService.judgeSFBA(info);
//				
//				// 是否宣称网站已备案，qrjrwz加字段SFXCYBA,宣称备案号XCBAH
//				webSiteStatusService.judgeSFXCYBA(webSiteStatus, info);
//				
//				webSiteStatusService.updateTestWebsiteInfoyxzt(info);
			} catch (Exception e) {
				e.printStackTrace();
				logger.error("测试-----网站状态判断异常..{}..",e);
				logger.error(info.toString());
			}
		}
	}

	private void test() {
		System.out.println("test");
	}

//	public WebSiteStatusService getWebSiteStatusService() {
//		return webSiteStatusService;
//	}
//
//	public void setWebSiteStatusService(WebSiteStatusService webSiteStatusService) {
//		this.webSiteStatusService = webSiteStatusService;
//	}
	/**
	 * 是否可连接外网
	 */
	private boolean validateOuternet(){
		return OuterNetValidate.isAvaliable();
	}	
	
}
